/**
 */
package de.thwildau.tm.moses.thrift.thrift.impl;

import de.thwildau.tm.moses.thrift.thrift.Annotation;
import de.thwildau.tm.moses.thrift.thrift.FieldType;
import de.thwildau.tm.moses.thrift.thrift.MapType;
import de.thwildau.tm.moses.thrift.thrift.ThriftPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Map Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.MapTypeImpl#getMapType1 <em>Map Type1</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.MapTypeImpl#getMapType1Annotation <em>Map Type1 Annotation</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.MapTypeImpl#getMapType2 <em>Map Type2</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.MapTypeImpl#getMapType2Annotation <em>Map Type2 Annotation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MapTypeImpl extends ContainerTypeImpl implements MapType
{
  /**
   * The cached value of the '{@link #getMapType1() <em>Map Type1</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMapType1()
   * @generated
   * @ordered
   */
  protected FieldType mapType1;

  /**
   * The cached value of the '{@link #getMapType1Annotation() <em>Map Type1 Annotation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMapType1Annotation()
   * @generated
   * @ordered
   */
  protected Annotation mapType1Annotation;

  /**
   * The cached value of the '{@link #getMapType2() <em>Map Type2</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMapType2()
   * @generated
   * @ordered
   */
  protected FieldType mapType2;

  /**
   * The cached value of the '{@link #getMapType2Annotation() <em>Map Type2 Annotation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMapType2Annotation()
   * @generated
   * @ordered
   */
  protected Annotation mapType2Annotation;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected MapTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ThriftPackage.Literals.MAP_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FieldType getMapType1()
  {
    return mapType1;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMapType1(FieldType newMapType1, NotificationChain msgs)
  {
    FieldType oldMapType1 = mapType1;
    mapType1 = newMapType1;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE1, oldMapType1, newMapType1);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMapType1(FieldType newMapType1)
  {
    if (newMapType1 != mapType1)
    {
      NotificationChain msgs = null;
      if (mapType1 != null)
        msgs = ((InternalEObject)mapType1).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE1, null, msgs);
      if (newMapType1 != null)
        msgs = ((InternalEObject)newMapType1).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE1, null, msgs);
      msgs = basicSetMapType1(newMapType1, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE1, newMapType1, newMapType1));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Annotation getMapType1Annotation()
  {
    return mapType1Annotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMapType1Annotation(Annotation newMapType1Annotation, NotificationChain msgs)
  {
    Annotation oldMapType1Annotation = mapType1Annotation;
    mapType1Annotation = newMapType1Annotation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION, oldMapType1Annotation, newMapType1Annotation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMapType1Annotation(Annotation newMapType1Annotation)
  {
    if (newMapType1Annotation != mapType1Annotation)
    {
      NotificationChain msgs = null;
      if (mapType1Annotation != null)
        msgs = ((InternalEObject)mapType1Annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION, null, msgs);
      if (newMapType1Annotation != null)
        msgs = ((InternalEObject)newMapType1Annotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION, null, msgs);
      msgs = basicSetMapType1Annotation(newMapType1Annotation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION, newMapType1Annotation, newMapType1Annotation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FieldType getMapType2()
  {
    return mapType2;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMapType2(FieldType newMapType2, NotificationChain msgs)
  {
    FieldType oldMapType2 = mapType2;
    mapType2 = newMapType2;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE2, oldMapType2, newMapType2);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMapType2(FieldType newMapType2)
  {
    if (newMapType2 != mapType2)
    {
      NotificationChain msgs = null;
      if (mapType2 != null)
        msgs = ((InternalEObject)mapType2).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE2, null, msgs);
      if (newMapType2 != null)
        msgs = ((InternalEObject)newMapType2).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE2, null, msgs);
      msgs = basicSetMapType2(newMapType2, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE2, newMapType2, newMapType2));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Annotation getMapType2Annotation()
  {
    return mapType2Annotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetMapType2Annotation(Annotation newMapType2Annotation, NotificationChain msgs)
  {
    Annotation oldMapType2Annotation = mapType2Annotation;
    mapType2Annotation = newMapType2Annotation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION, oldMapType2Annotation, newMapType2Annotation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMapType2Annotation(Annotation newMapType2Annotation)
  {
    if (newMapType2Annotation != mapType2Annotation)
    {
      NotificationChain msgs = null;
      if (mapType2Annotation != null)
        msgs = ((InternalEObject)mapType2Annotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION, null, msgs);
      if (newMapType2Annotation != null)
        msgs = ((InternalEObject)newMapType2Annotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION, null, msgs);
      msgs = basicSetMapType2Annotation(newMapType2Annotation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION, newMapType2Annotation, newMapType2Annotation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case ThriftPackage.MAP_TYPE__MAP_TYPE1:
        return basicSetMapType1(null, msgs);
      case ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION:
        return basicSetMapType1Annotation(null, msgs);
      case ThriftPackage.MAP_TYPE__MAP_TYPE2:
        return basicSetMapType2(null, msgs);
      case ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION:
        return basicSetMapType2Annotation(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ThriftPackage.MAP_TYPE__MAP_TYPE1:
        return getMapType1();
      case ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION:
        return getMapType1Annotation();
      case ThriftPackage.MAP_TYPE__MAP_TYPE2:
        return getMapType2();
      case ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION:
        return getMapType2Annotation();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ThriftPackage.MAP_TYPE__MAP_TYPE1:
        setMapType1((FieldType)newValue);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION:
        setMapType1Annotation((Annotation)newValue);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2:
        setMapType2((FieldType)newValue);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION:
        setMapType2Annotation((Annotation)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.MAP_TYPE__MAP_TYPE1:
        setMapType1((FieldType)null);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION:
        setMapType1Annotation((Annotation)null);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2:
        setMapType2((FieldType)null);
        return;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION:
        setMapType2Annotation((Annotation)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.MAP_TYPE__MAP_TYPE1:
        return mapType1 != null;
      case ThriftPackage.MAP_TYPE__MAP_TYPE1_ANNOTATION:
        return mapType1Annotation != null;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2:
        return mapType2 != null;
      case ThriftPackage.MAP_TYPE__MAP_TYPE2_ANNOTATION:
        return mapType2Annotation != null;
    }
    return super.eIsSet(featureID);
  }

} //MapTypeImpl
